package com.easyjava.init;

import com.easyjava.bean.TableInfo;
import com.easyjava.builder.BuildVo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.easyjava.bean.Constants.CREATE_CASCADE_QUERY;

/**
 * @Author: 小闹心
 * @Description: 初始化级联删除
 * @DateTime: 2025/6/19 18:32
 **/
public class InitCascade {
    public static final Map<String, List<String>> CASCADE_TABLE_MAP = new HashMap<>();
    public static final Map<String, String> CASCADE_FIELD_RELATION_MAP = new HashMap<>();

    public static final Map<String, TableInfo> TABLE_INFO_MAP = new HashMap<>();
    public static void execute(List<TableInfo> tableInfos){
        for(TableInfo tableInfo : tableInfos){
            TABLE_INFO_MAP.put(tableInfo.getTableName(), tableInfo);
        }
        for(String cascade : CREATE_CASCADE_QUERY){
            String[] bd = cascade.split(" ", 2);
            // 创建连表查询所表现的Po
            BuildVo.execute(bd);
        }
    }
}
